package com.java.comprehensive.design.behavioral_model.state_patten.heima.before;

public class Lift implements ILift {
    private int state;

    @Override
    public void setStat(int stat) {
        this.state = stat;
    }

    @Override
    public void open() {
        switch (state) {//当前电梯状态
            case OPEN_STATE:
                System.out.println("无事发生");
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了");
                break;
            case RUNNING_STATE:
                System.out.println("无事发生");
                break;
            case STOPPING_STATE:
                System.out.println("电梯打开了");
                break;
        }
    }

    @Override
    public void close() {
        switch (state) {//当前电梯状态
            case OPEN_STATE:
                System.out.println("电梯关闭了");
                break;
            case CLOSING_STATE:
                System.out.println("无事发生");
                break;
            case RUNNING_STATE:
                System.out.println("无事发生");
                break;
            case STOPPING_STATE:
                System.out.println("无事发生");
                break;
        }
    }

    @Override
    public void run() {
        switch (state) {//当前电梯状态
            case OPEN_STATE:
                System.out.println("无事发生");
                break;
            case CLOSING_STATE:
                System.out.println("电梯运行");
                break;
            case RUNNING_STATE:
                System.out.println("无事发生");
                break;
            case STOPPING_STATE:
                System.out.println("电梯运行");
                break;
        }
    }

    @Override
    public void stop() {
        switch (state) {//当前电梯状态
            case OPEN_STATE:
                System.out.println("无事发生");
                break;
            case CLOSING_STATE:
                System.out.println("无事发生");
                break;
            case RUNNING_STATE:
                System.out.println("电梯停止");
                break;
            case STOPPING_STATE:
                System.out.println("无事发生");
                break;
        }
    }
}
